"""
面向对象和面向过程类和对象
属性和方法

类的定义
class类名(:
pass
如果一个类未明确指明父类，则默认继承自object
"""
# def main():
#     aaa=[1,2,3,4,5,6,7,8,9,0]
#     print(aaa[0:3])
#     print(aaa[1:-1])
#     print(aaa[-4:])
#     print(aaa[:3])
#     print(aaa[2:-1:2])
#
#
#
# if __name__ == "__main__":
#     main()
# class Info(object):
#     pass
# class computer(object):
#     def __new__(cls, *args, **kwargs):
#         print('new方法')
#         return object.__new__(cls)
#     def __init__(self,color,weight,price):
#         """初始化方法"""
#         print('init方法')
#         self.color=color
#         self.weight=weight
#         self.price=price
#     def play_game(self):
#         print('可以打游戏')
#     def write_code(self):
#         print('写代码')
#     def __str__(self):
#         return self.color
# def main():
#     Huawei=computer('灰',2,6000)
#     mac=computer('银',1.5,8000)
#     print(Huawei.price)
#     print(mac.price)
# if __name__=='__main__':
#     main()
class Vector:
    def __init__(self, a, b):
        self.a = a
        self.b = b

    def __str__(self):
        return 'Vector (%d, %d)' % (self.a, self.b)

    def __add__(self, other):
        return Vector(self.a + other.a, self.b + other.b)

v1 = Vector(2, 10)
print(v1)
v2 = Vector(5, -2)
print(v2)
print(v1 + v2)
